﻿using Soft.Xml;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml;

namespace Soft.Service
{

    /// <summary>
    /// 封装xml配置文件中ClassConfig节点
    /// </summary>
    public sealed class ClassConfig : BaseSubElement
    {

        public ClassConfig(XmlElement current) : base(current)
        {
        }


        /// <summary>
        /// 获取Class的节点信息
        /// </summary>
        public string Class
        {
            get
            {
                return base.CurrentElement.GetAttribute("Class");
            }
            set
            {
                base.CurrentElement.SetAttribute("Class", value);
            }
        }


        /// <summary>
        /// 启动方式
        /// </summary>
        public JobServiceStartType StartType
        {
            get
            {
                string value = base.CurrentElement.GetAttribute("StartType").Trim();
                if (string.IsNullOrWhiteSpace(value))
                {
                    return JobServiceStartType.Automatic;
                }
                return value.ConvertTo(JobServiceStartType.Automatic, true);
            }
            set
            {
                base.CurrentElement.SetAttribute("StartType", value.ToString());
            }
        }


        /// <summary>
        /// 获取ClassConfig节点下的 TimedTasks节点下，表示定时任务元数据集合
        /// </summary>
        public TimedTaskCollection TimedTasks
        {
            get
            {
                return base.GetObjectElement<TimedTaskCollection>("TimedTasks");
            }
        }


    }
}
